
$(function () {
	//页面初始化
	if($("#ship").val()==2){
		$("#shipMethod option[value='2']").attr("selected",true);
	}else if($("#ship").val()==1){
		$("#shipMethod option[value='1']").attr("selected",true);
	}else if($("#ship").val()==3){
		$("#shipMethod option[value='3']").attr("selected",true);
	}
	
	//兑奖时间
	$('#cashTime_start').daterangepicker({
		"singleDatePicker": true,
		"timePicker": true,
		"timePicker24Hour": true,
		"timePickerSeconds": true,
		"autoApply": true,
		"parentEl": "200",
		locale: {
			format: 'YYYY-MM-DD HH:mm:ss'
		}
	}, function(start, end, label) {
		$('#cashTime_start').val(start.format('YYYY-MM-DD HH:mm:ss'));
		$("#cashTimeS").val(start+"");
	});
	$("#cashTime_start").val("");//清空控件默认时间
	
	$('#cashTime_end').daterangepicker({
		"singleDatePicker": true,
		"timePicker": true,
		"timePicker24Hour": true,
		"timePickerSeconds": true,
		"autoApply": true,
		"parentEl": "200",
		locale: {
			format: 'YYYY-MM-DD HH:mm:ss'
		}
	}, function(start, end, label) {
		$('#cashTime_end').val(start.format('YYYY-MM-DD HH:mm:ss'));
		$("#cashTimeE").val(start+"");
	});
	$('#cashTime_end').val("");//清空控件默认时间
	
	//扫码时间 
	//在非触发方法取得日期值
	//var start = $('#winning_start').daterangepicker().data('daterangepicker').startDate;
	$('#winning_start').daterangepicker({
		"singleDatePicker": true,
		"timePicker": true,
		"timePicker24Hour": true,
		"timePickerSeconds": true,
		"autoApply": true,
		"parentEl": "200",
		locale: {
			format: 'YYYY-MM-DD HH:mm:ss'
		}
	}, function(start, end, label) {
		$('#winning_start').val(start.format('YYYY-MM-DD HH:mm:ss'));
	});
	$('#winning_start').val("");//清空控件默认时间
	
	$('#winning_end').daterangepicker({
		"singleDatePicker": true,
		"timePicker": true,
		"timePicker24Hour": true,
		"timePickerSeconds": true,
		"autoApply": true,
		"parentEl": "200",
		locale: {
			format: 'YYYY-MM-DD HH:mm:ss'
		}
	}, function(start, end, label) {
		$('#winning_end').val(start.format('YYYY-MM-DD HH:mm:ss'));
	});
	$('#winning_end').val("");//清空控件默认时间
	
	//日期时间查询条件不为空的情况下，给控件赋值
	if($("#scanTimeS_hidden").val() != null || $("#scanTimeS_hidden").val() != ""){
		$("#winning_start").val($("#scanTimeS_hidden").val());
	}
	if($("#scanTimeE_hidden").val() != null || $("#scanTimeE_hidden").val() != ""){
		$("#winning_end").val($("#scanTimeE_hidden").val());
	}
	if($("#cashTimeS_hidden").val() != null || $("#cashTimeS_hidden").val() != ""){
		$("#cashTime_start").val($("#cashTimeS_hidden").val());
	}
	if($("#cashTimeE_hidden").val() != null || $("#cashTimeE_hidden").val() != ""){
		$("#cashTime_end").val($("#cashTimeE_hidden").val());
	}
	
	
	


	//点击列表中"详情"按钮
	$("[name='btn_detail_winning']").click(function(){
		
		var winningId = $(this).data("winning-id");
		window.location.href="/activitywinning?id="+winningId;
	});
	
    
	
	
	




   


});
//===================以下为公共方法============================

/**   
*转换long值为日期字符串   
* @param l long值   
* @param pattern 格式字符串,例如：yyyy-MM-dd hh:mm:ss   
* @return 符合要求的日期字符串   
*/    

function getFormatDateByLong(l, pattern) {  
    return getFormatDate(new Date(l), pattern);  
}
/**   
 *转换日期对象为日期字符串   
 * @param l long值   
 * @param pattern 格式字符串,例如：yyyy-MM-dd hh:mm:ss   
 * @return 符合要求的日期字符串   
 */    
 function getFormatDate(date, pattern) {  
     if (date == undefined) {  
         date = new Date();  
     }  
     if (pattern == undefined) {  
         pattern = "yyyy-MM-dd hh:mm:ss";  
     }  
     return date.format(pattern);  
 }
//扩展Date的format方法   
 Date.prototype.format = function (format) {  
     var o = {  
         "M+": this.getMonth() + 1,  
         "d+": this.getDate(),  
         "h+": this.getHours(),  
         "m+": this.getMinutes(),  
         "s+": this.getSeconds(),  
         "q+": Math.floor((this.getMonth() + 3) / 3),  
         "S": this.getMilliseconds()  
     }  
     if (/(y+)/.test(format)) {  
         format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
     }  
     for (var k in o) {  
         if (new RegExp("(" + k + ")").test(format)) {  
             format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));  
         }  
     }  
     return format;  
 } 